//
//  HWTouristsView.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/12.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWTouristsView.h"

@interface HWTouristsView()
@property(strong,nonatomic) UIView *grayView;
@property(strong,nonatomic) UIView *fenxiangView;
@property(strong,nonatomic) UILabel *diyigeLabel;
@property(strong,nonatomic) UILabel*dia2Label;
@end


@implementation HWTouristsView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // 添加灰色背景
        [self addgrayView];
        
        [self setupUI];
    }
    
    return  self;
    
}


//  设置UI
- (void)setupUI {
    
    
     self.fenxiangView = [[UIView alloc]initWithFrame:CGRectMake(43, (kScreenH-(143*CFLScaleValue+118))/2, kScreenW-43*2,143*CFLScaleValue+117)];
      self.fenxiangView.layer.cornerRadius = 6;
      self.fenxiangView.layer.masksToBounds = YES;
      self.fenxiangView.backgroundColor =[UIColor whiteColor];

     [self addSubview:self.fenxiangView];
    
    UIImageView *imaview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW-43*2, 143*CFLScaleValue)];
    imaview.image = [UIImage imageNamed:@"tourists_sign_savebg"];
    [self.fenxiangView addSubview:imaview];
    
    UILabel *miaoshuLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, 143*CFLScaleValue+23, kScreenW-43*2, 13)];
    miaoshuLabel.font = [UIFont systemFontOfSize:13];
    miaoshuLabel.text = @"你需要保存用户信息";
    miaoshuLabel.textColor = RGB(51, 51, 51);

    [self.fenxiangView addSubview:miaoshuLabel];
    
    
    UILabel *zhanhaomiaoshuLabel = [[UILabel alloc]initWithFrame:CGRectMake(27, miaoshuLabel.bottom+10, kScreenW-43*2, 13)];
    zhanhaomiaoshuLabel.font = [UIFont systemFontOfSize:12];
    zhanhaomiaoshuLabel.text = @"";
    zhanhaomiaoshuLabel.textColor = RGB(153, 153, 153);
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"账号：5BxB54s" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]}];
    zhanhaomiaoshuLabel.attributedText = string;
    self.diyigeLabel = zhanhaomiaoshuLabel;
    
    [self.fenxiangView addSubview:zhanhaomiaoshuLabel];
    
    
    UILabel *mimalabe = [[UILabel alloc]initWithFrame:CGRectMake(27, zhanhaomiaoshuLabel.bottom+6, kScreenW-43*2, 13)];
    mimalabe.font = [UIFont systemFontOfSize:12];
    mimalabe.text = @"";
    mimalabe.textColor = RGB(153, 153, 153);
    NSMutableAttributedString *string1 = [[NSMutableAttributedString alloc] initWithString:@"密码：J5ksA54"  attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]}];
    mimalabe.attributedText = string1;
    self.dia2Label =  mimalabe;
    
    [self.fenxiangView addSubview:mimalabe];
    
    
    UIButton *butt  = [UIButton setButtonWithFrame:CGRectMake(kScreenW-43*2-55-15, self.fenxiangView.height-30, 60, 30) Title:@"我已知晓" Image:nil Font:13 Color:RGB(66, 134, 245) Target:self Selector:@selector(buttonTap)];
    
    [self.fenxiangView addSubview:butt];
   
    
    
}

- (void)buttonTap {
    
    [self.delegate jizhu];
    
    
    [self removeFromSuperview];
}

-(void)setDataDic:(NSDictionary *)dataDic {
    
    
    _dataDic = dataDic;
    
    NSString *str = [NSString stringWithFormat:@"账号：%@",dataDic[@"user_name"]];

    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]}];
    
    self.diyigeLabel.attributedText = string;
    
    
    
      NSString *str1 = [NSString stringWithFormat:@"密码：%@",dataDic[@"passwd"]];
    
      NSMutableAttributedString *string1 = [[NSMutableAttributedString alloc] initWithString:str1 attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0]}];
    
    self.dia2Label.attributedText = string1;
    
}




// 添加灰色View
-(void)addgrayView {
    
    self.grayView = [[UIView alloc]init];
    self.grayView.frame  = CGRectMake(0,0, kScreenW, kScreenH);
    
    self.grayView.backgroundColor =  RGB(51, 51, 51);
    self.grayView.alpha = 0.8;
    [self addSubview:self.grayView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapView:)];
    //  tap.delegate = self;
    [self.grayView addGestureRecognizer:tap];
    
    
}

- (void)tapView:(UITapGestureRecognizer *)touch {
    
  //  [touch.view.superview removeFromSuperview];
    //   [[NSNotificationCenter defaultCenter] postNotificationName:@"notifyName1" object:nil];
    
    
}


@end
